#pragma once
#ifndef CALCULATORS_H
#define CALCULATORS_H

double calculate_b(double a, int s)
{
    double temp1, temp2, temp3;
    double i;
    temp3 = 1;
    for (i = 1; i <= s; i++){
        temp1 = a*temp3;
        temp2 = i + temp1;
        temp3 = temp1 / temp2;
    }
    return temp3;
}

double calculate_a(int s, double b)
{
    double a, ec;
    double temp4;
    ec = 0.0001;
    temp4 = 0;
    for (a = 0.01; temp4 - b >= ec || temp4 - b <= -ec; a += 0.001){
        temp4 = calculate_b(a, s);
    }
    return a;
}

int calculate_s(double b, double a)
{
    int s;
    double temp4, ec;
    ec = 0.0001;
    temp4 = 1;
    for (s = 1; (temp4 - b) >= ec; s++){
        temp4 = calculate_b(a, s);
    }
    return s;
}

#endif // CALCULATORS_H
